package io.starteos.wallet.utils.eos.bean;



import com.google.gson.annotations.Expose;

import io.starteos.wallet.utils.eos.crypto.util.HexUtils;
import io.starteos.wallet.utils.eos.data.remote.model.types.EosByteWriter;
import io.starteos.wallet.utils.eos.data.remote.model.types.EosType;
import io.starteos.wallet.utils.eos.data.remote.model.types.TypeAccountName;


/**
 * Created by haichecker on 18-6-21.
 */

public class EosBuyramBytes implements EosType.Packer {
    @Expose
    private int bytes;
    @Expose
    private TypeAccountName payer;
    @Expose
    private TypeAccountName receiver;
    
    public String getActionName() {
    	return "buyrambytes";
	}

    public EosBuyramBytes(int bytes, String payer, String receiver) {
        this(bytes, new TypeAccountName(payer), new TypeAccountName(receiver));
    }

    public EosBuyramBytes(int bytes, TypeAccountName payer, TypeAccountName receiver) {
        this.bytes = bytes;
        this.payer = payer;
        this.receiver = receiver;
    }

    @Override
    public void pack(EosType.Writer writer) {
        payer.pack(writer);
        receiver.pack(writer);
        writer.putIntLE(bytes);
    }

    public String getHex() {
        EosType.Writer writer = new EosByteWriter(128);
        pack(writer);
        return HexUtils.toHex(writer.toBytes());
    }
}
